cmake_minimum_required(VERSION 3.15)

project(duilib_pro C CXX)

#add_definitions(-g -Wall -O3)

# -D开表示宏定义
if(MSVC)
  add_definitions(-D_WIN32_WINNT=0x600)
  add_compile_options("/source-charset:utf-8")
  add_definitions(-DNOMINMAX) # disable msvc max/min
  set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS True )
endif()


include_directories(comm render shell components)

message(STATUS "Begain build library ...")
set(LIB_SRC 
  "./shell/win_nt.cpp"
  "./shell/msg_core.cpp"
  "./render/win_gdi.cpp"
  "./comm/comm.cpp"
  "./components/UIContainer.cpp"
  "./components/UILabel.cpp"
  "./components/UIEdit.cpp"
  "./components/UICheckBox.cpp"
  "./components/UIComboBox.cpp"
  "./components/UIScrollContainer.cpp"
)

add_library(${PROJECT_NAME} ${LIB_SRC})
if(MSVC)
  target_link_libraries(${PROJECT_NAME} kernel32 user32 gdi32 shell32 advapi32 comdlg32 gdiplus Imm32)
endif ()


message(STATUS "Begain build exe ...")

set(SIMPLE_SRC
  "./test/simple/main.cpp"
)
add_executable(simple ${SIMPLE_SRC} logo.rc)
target_link_libraries(simple ${PROJECT_NAME})
# if(MSVC)
#  set_target_properties(simple PROPERTIES
#          LINK_FLAGS "/subsystem:windows /entry:mainCRTStartup"
#  )
# endif()

message(STATUS "Copy resource...")
add_custom_command(TARGET simple POST_BUILD   
  COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${PROJECT_SOURCE_DIR}/logo.ico" $<TARGET_FILE_DIR:simple>
  COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${PROJECT_SOURCE_DIR}/logo.png" $<TARGET_FILE_DIR:simple>
  COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${PROJECT_SOURCE_DIR}/9ge.png" $<TARGET_FILE_DIR:simple>
) 



set(BASE_SRC
  "./test/base/main.cpp"
)
add_executable(base ${BASE_SRC})
set_target_properties(base PROPERTIES
LINK_FLAGS "/subsystem:windows /entry:mainCRTStartup"
)

message(STATUS "build End")
